package zj.com.model;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.junit.Test;

import java.io.IOException;

public class JsoupCrawler {
    @Test
    public void test(){

        try {
            String word="罐车";
            Integer limit=10;
            Integer page=0;
            while (page<limit){
                String url="https://image.baidu.com/search/acjson?tn=resultjson_com&ipn=rj&ct=201326592&fp=result&queryWord="+word+"&cl=2&lm=-1&ie=utf-8&oe=utf-8&st=-1&word="+word+"&face=0&istype=2&nc=1&pn="+page*30+"&rn=30";
                Connection.Response execute = Jsoup.connect(url).ignoreContentType(true).execute();
                String body = execute.body();
                JSONObject jsonObject = JSON.parseObject(body);

                page++;
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
